<?php
namespace app\teacher\controller;

use app\teacher\model\News;
use app\teacher\model\Newstype;
use app\teacher\model\Slideshow;
use app\teacher\model\Text;
use think\Session;

class  Indexs extends Base
{
    public function index(){
        //$user = $this->user_info();
        //轮播图
        $slide = Slideshow::where(["status"=>1])->order("sort desc")->select();
        //热卖新闻7条
        $news = News::order("sorttype asc")->limit(7)->select();
        foreach($news as $k => $v){
            $type = Newstype::where(array("id"=>$v['newstype']))->find();
            $news[$k]['tt'] = mb_substr($type['type_name'],0,1,"utf-8");
        }
        $teacher = [
          "is_attendances"=>2
        ];
        if(Session::has("teacher_infos")){
            $teacher = Session::get("teacher_infos");
        }
        //查询热门推荐信息
        $rmtj = Text::where(array("k"=>'rmtj'))->find();
        $data = array(
            "setting" => $this->getAllSetting(),
            "slide" => $slide,
            "news"=>$news,
            "rmtj"=>$rmtj['val'],
            "teacher"=>$teacher,
        );
        return view("index",$data);
    }
}
